package com.cat.service.imlp;

import com.alibaba.dubbo.config.annotation.Service;
import com.cat.dao.BaseDao;
import com.cat.dao.PermissionDao;
import com.cat.entity.Permission;
import com.cat.service.PermissionService;
import com.cat.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Service(interfaceClass = PermissionService.class)
public class PermissionServiceImpl extends BaseServiceImpl<Permission> implements PermissionService {
    @Autowired
    private PermissionDao permissionDao;
    @Override
    protected BaseDao<Permission> getEntityDao() {
        return null;
    }
    @Override
    public List<String> findCodeListByAdminId(Long adminId) {
        //超级管理员admin账号id为：1
        if(adminId.longValue() == 1) {
            //返回所有的权限限制
            return permissionDao.findAllCodeList();
        }
        //返回id所属的权限
        return permissionDao.findCodeListByAdminId(adminId);
    }
}
